/**
 * 				IpInput.java
 *				------------
 *		
 *   Author:	Moser Dominik
 *   ID:		bin04017
 *	 Created:	18.12.2006
 *	 Project:	Mochito-MP3-Sync
 *	 Package:	gui
 *	 Usage:		
 */
package gui;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 * @author bin04017
 *
 */
public class IpInput extends JFrame implements ActionListener{

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JButton jButton = null;

	private JTextField jTextField = null;
	
	private String ip = null;
	
	/**
	 * This is the default constructor
	 */
	public IpInput() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 70);
		this.setContentPane(getJContentPane());
		this.setTitle("Set Ip");
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				System.exit(0);
			}
		});
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new FlowLayout());
			jContentPane.add(getJButton(), null);
			jContentPane.add(getJTextField(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("Commit");
			jButton.addActionListener(this);
		}
		return jButton;
	}

	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setText("192.168.0.1");
		}
		return jTextField;
	}

	public String getIp() {
		return ip;
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(jButton)){
			this.setVisible(false);
			ip = jTextField.getText();
		}
	}

	
}  //  @jve:decl-index=0:visual-constraint="10,10"
